﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaixin.Components.InterFace;
using ComponentFactory.Krypton.Toolkit;
using System.Windows.Forms;
using Kaixin.Components.Tycoon.BLL;

namespace Kaixin.Components.Tycoon.PanelFactory
{
    class GoodsUIFactory:IUIPanelFactory
    {

        private ComponentFactory.Krypton.Toolkit.KryptonPanel ktpanel;
        private ComponentFactory.Krypton.Toolkit.KryptonBorderEdge kryptonBorderEdge1;
        private ComponentFactory.Krypton.Toolkit.KryptonComboBox kcbGoodsConditions;
        private ComponentFactory.Krypton.Toolkit.KryptonLabel kryptonLabel1;
        private ComponentFactory.Krypton.Toolkit.KryptonLabel kryptonLabel2;
        private ComponentFactory.Krypton.Toolkit.KryptonTextBox txtGoodsPrice;
        private ComponentFactory.Krypton.Toolkit.KryptonDataGridView dgvGoods;
        private ComponentFactory.Krypton.Toolkit.KryptonButton btnSearchGoods;

        private void InitializeComponent()
        {
            this.ktpanel = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
            this.kryptonBorderEdge1 = new ComponentFactory.Krypton.Toolkit.KryptonBorderEdge();
            this.kryptonLabel1 = new ComponentFactory.Krypton.Toolkit.KryptonLabel();
            this.kcbGoodsConditions = new ComponentFactory.Krypton.Toolkit.KryptonComboBox();
            this.txtGoodsPrice = new ComponentFactory.Krypton.Toolkit.KryptonTextBox();
            this.kryptonLabel2 = new ComponentFactory.Krypton.Toolkit.KryptonLabel();
            this.dgvGoods = new ComponentFactory.Krypton.Toolkit.KryptonDataGridView();
            this.btnSearchGoods = new ComponentFactory.Krypton.Toolkit.KryptonButton();
           
            // 
            // ktpanel
            // 
            this.ktpanel.Controls.Add(this.btnSearchGoods);
            this.ktpanel.Controls.Add(this.dgvGoods);
            this.ktpanel.Controls.Add(this.kryptonLabel2);
            this.ktpanel.Controls.Add(this.txtGoodsPrice);
            this.ktpanel.Controls.Add(this.kcbGoodsConditions);
            this.ktpanel.Controls.Add(this.kryptonLabel1);
            this.ktpanel.Controls.Add(this.kryptonBorderEdge1);
            this.ktpanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.ktpanel.Location = new System.Drawing.Point(0, 0);
            this.ktpanel.Name = "ktpanel";
            this.ktpanel.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.ktpanel.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelClient;
            this.ktpanel.Size = new System.Drawing.Size(992, 568);
            this.ktpanel.TabIndex = 0;
            // 
            // kryptonBorderEdge1
            // 
            this.kryptonBorderEdge1.BorderStyle = ComponentFactory.Krypton.Toolkit.PaletteBorderStyle.ControlClient;
            this.kryptonBorderEdge1.Location = new System.Drawing.Point(3, 104);
            this.kryptonBorderEdge1.Name = "kryptonBorderEdge1";
            this.kryptonBorderEdge1.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.kryptonBorderEdge1.Size = new System.Drawing.Size(1000, 1);
            this.kryptonBorderEdge1.TabIndex = 0;
            this.kryptonBorderEdge1.Text = "kryptonBorderEdge1";
            // 
            // kryptonLabel1
            // 
            this.kryptonLabel1.LabelStyle = ComponentFactory.Krypton.Toolkit.LabelStyle.NormalControl;
            this.kryptonLabel1.Location = new System.Drawing.Point(21, 45);
            this.kryptonLabel1.Name = "kryptonLabel1";
            this.kryptonLabel1.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.kryptonLabel1.Size = new System.Drawing.Size(85, 19);
            this.kryptonLabel1.TabIndex = 1;
            this.kryptonLabel1.Text = "物品最小价值";
            this.kryptonLabel1.Values.ExtraText = "";
            this.kryptonLabel1.Values.Image = null;
            this.kryptonLabel1.Values.Text = "物品最小价值";
            // 
            // kcbGoodsConditions
            // 
            this.kcbGoodsConditions.DropBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.ControlClient;
            this.kcbGoodsConditions.DropButtonStyle = ComponentFactory.Krypton.Toolkit.ButtonStyle.InputControl;
            this.kcbGoodsConditions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.kcbGoodsConditions.DropDownWidth = 50;
            this.kcbGoodsConditions.InputControlStyle = ComponentFactory.Krypton.Toolkit.InputControlStyle.Standalone;
            this.kcbGoodsConditions.Items.AddRange(new object[] {
            "大于",
            "小于"});
            this.kcbGoodsConditions.ItemStyle = ComponentFactory.Krypton.Toolkit.ButtonStyle.ListItem;
            this.kcbGoodsConditions.Location = new System.Drawing.Point(112, 42);
            this.kcbGoodsConditions.Name = "kcbGoodsConditions";
            this.kcbGoodsConditions.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.kcbGoodsConditions.Size = new System.Drawing.Size(50, 22);
            this.kcbGoodsConditions.TabIndex = 2;
            // 
            // txtGoodsPrice
            // 
            this.txtGoodsPrice.InputControlStyle = ComponentFactory.Krypton.Toolkit.InputControlStyle.Standalone;
            this.txtGoodsPrice.Location = new System.Drawing.Point(168, 42);
            this.txtGoodsPrice.Name = "txtGoodsPrice";
            this.txtGoodsPrice.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.txtGoodsPrice.Size = new System.Drawing.Size(66, 22);
            this.txtGoodsPrice.TabIndex = 3;
            this.txtGoodsPrice.Text = "0";
            // 
            // kryptonLabel2
            // 
            this.kryptonLabel2.LabelStyle = ComponentFactory.Krypton.Toolkit.LabelStyle.NormalControl;
            this.kryptonLabel2.Location = new System.Drawing.Point(240, 42);
            this.kryptonLabel2.Name = "kryptonLabel2";
            this.kryptonLabel2.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.kryptonLabel2.Size = new System.Drawing.Size(35, 19);
            this.kryptonLabel2.TabIndex = 4;
            this.kryptonLabel2.Text = "万元";
            this.kryptonLabel2.Values.ExtraText = "";
            this.kryptonLabel2.Values.Image = null;
            this.kryptonLabel2.Values.Text = "万元";
            // 
            // dgvGoods
            // 
            this.dgvGoods.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.dgvGoods.GridStyles.Style = ComponentFactory.Krypton.Toolkit.DataGridViewStyle.List;
            this.dgvGoods.GridStyles.StyleBackground = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.GridBackgroundList;
            this.dgvGoods.GridStyles.StyleColumn = ComponentFactory.Krypton.Toolkit.GridStyle.List;
            this.dgvGoods.GridStyles.StyleDataCells = ComponentFactory.Krypton.Toolkit.GridStyle.List;
            this.dgvGoods.GridStyles.StyleRow = ComponentFactory.Krypton.Toolkit.GridStyle.List;
            this.dgvGoods.Location = new System.Drawing.Point(0, 111);
            this.dgvGoods.Name = "dgvGoods";
            this.dgvGoods.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.dgvGoods.RowTemplate.Height = 23;
            this.dgvGoods.Size = new System.Drawing.Size(992, 457);
            this.dgvGoods.StateCommon.BackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.GridBackgroundList;
            this.dgvGoods.TabIndex = 5;
            // 
            // btnSearchGoods
            // 
            this.btnSearchGoods.ButtonStyle = ComponentFactory.Krypton.Toolkit.ButtonStyle.Standalone;
            this.btnSearchGoods.Location = new System.Drawing.Point(281, 42);
            this.btnSearchGoods.Name = "btnSearchGoods";
            this.btnSearchGoods.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.btnSearchGoods.Size = new System.Drawing.Size(90, 25);
            this.btnSearchGoods.TabIndex = 6;
            this.btnSearchGoods.Text = "查询";
            this.btnSearchGoods.Values.ExtraText = "";
            this.btnSearchGoods.Values.Image = null;
            this.btnSearchGoods.Values.ImageStates.ImageCheckedNormal = null;
            this.btnSearchGoods.Values.ImageStates.ImageCheckedPressed = null;
            this.btnSearchGoods.Values.ImageStates.ImageCheckedTracking = null;
            this.btnSearchGoods.Values.Text = "查询";
           
            //init
            kcbGoodsConditions.SelectedIndex = 0;
            btnSearchGoods.Click += new EventHandler(btnSearchGoods_Click);
        
        }

        void btnSearchGoods_Click(object sender, EventArgs e)
        {
            TycoonRobot tr = new TycoonRobot();
            if (kcbGoodsConditions.SelectedItem.ToString() == "大于")
            {
               dgvGoods.DataSource = tr.GetTOP10(g => g.MinPrice >= int.Parse(txtGoodsPrice.Text) * 10000);
            }
            else
            {
                dgvGoods.DataSource = tr.GetTOP10(g => g.MinPrice <= int.Parse(txtGoodsPrice.Text) * 10000);
            }
        }


        #region IUIPanelFactory 成员

        public Panel CreatePanel()
        {
            InitializeComponent();
            return ktpanel;
        }

        #endregion
    }
}
